package com.leetcode.regex;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Dennis Li
 * @date 2020/9/17 21:14
 */
public class Regex {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Pattern pattern1 = Pattern.compile("^(\\D*)([1-3]\\d{3})(\\D*)$");
        Pattern pattern2 = Pattern.compile("^[1-3]\\d{3}");

        String str = "asda1234sadasd";

        Matcher m = pattern1.matcher(str);

        while (m.find()) {
            String group = m.group();
            System.out.println(m.start());
            System.out.println(group.substring(m.start() + 1, m.start() + 5));
        }
    }

}
